GBML manual / Paths

path_end_do

What happens when this instance reaches the end of its path - always one of the PATH_* constants (PATH_STOP, PATH_LOOP, PATH_PING_PONG, PATH_CONTINUE). path_start()’s third argument sets it; read or assign it any time to check or change what the path does when it runs out.

Syntax

path_end_do: constant

Description

What happens when this instance reaches the end of its path - always one of PATH_STOP, PATH_LOOP, PATH_PING_PONG or PATH_CONTINUE. path_start's third argument sets it. You can also read it or assign it at any time, to check what the path is going to do or to change your mind while the instance is on the way. See Rooms's own "Paths, briefly" section for what each of the four actually does.

It is one of the four end actions, not a number. That has three consequences:

An assignment takes effect the next time this instance reaches the end of its path. It does not move the instance and it does not restart the path. An instance that never started a path reads PATH_STOP.

Example

if (path_pos > 0.9 and path_end_do == PATH_LOOP) {
    path_end_do = PATH_STOP;
}

An instance that was told to loop is close to the end of its lap. This changes its mind, so it stops there instead of starting another lap.

path_start(path_doc_patrol, 1, PATH_PING_PONG, false);
var chosen = path_end_do;

path_start stores PATH_PING_PONG, so chosen holds it straight away. Reading path_end_do right after starting a path shows what the path was started with.

On the GBA

Compares equal to the PATH_* constants (`if (path_end_do == PATH_LOOP)`), and assigning one takes effect the next time this instance reaches the end of its path, not before. It is a value of its own kind, not a number: `path_end_do = 2;`, `path_end_do == 1`, `path_end_do + 1` and `path_end_do++` are all refused by the checker. The engine keeps it as a plain whole number inside the instance, and the generated code converts to and from PATH_* on every read and write - you never see the number. An instance that never started a path reads PATH_STOP.

See also: Roomspath_startpath_stopPATH_STOPPATH_LOOPPATH_PING_PONGPATH_CONTINUE